{extend name='public/base' /}

{block name="content"}
<style type="text/css">
    .layui-form-pane .layui-form-label {
        overflow: initial !important;
    }

    .tanchu {
        position: absolute;
        top: 170px;
        left: 440px;
        background-color: #fff;
        border: #ccc solid 1px;
        width: 1000px;
        border-radius: 10px;
    }
</style>
<div class="layui-col-md12">
    <div class="layui-card">
        <div class="layui-card-body">
            <form action="" class="layui-form" method="get">
                <div class="layui-form-item layui-form-pane">
                    <div class="layui-inline">
                        <label class="layui-form-label">商户：</label>
                        <div class="layui-input-inline">
                            <select name="merchant_id" lay-verify="required" lay-search="">
                                <option value=""></option>
                                {volist name="merchant_list" id="t"}
                                {if empty($t.name)||$t.name=='-'}
                                <option value="{$t.id}">{$t.company} - {$t.code}-{$t.biz_state}-{$t.positions_code}
                                </option>
                                {else/}
                                <option value="{$t.id}">{$t.name} - {$t.code}-{$t.biz_state}-{$t.positions_code}
                                </option>
                                {/if}
                                {/volist}
                            </select>
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label" style="overflow: inherit;">合同编号：</label>
                        <div class="layui-input-inline">
                            <input name="code" class="layui-input" id="code" value="" type="text"
                                   placeholder="合同编号">
                        </div>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">审核状态：</label>
                        <div class="layui-input-inline">
                            <select name="status" lay-verify="required" lay-search="">
                                <option value="">请选择</option>
                                <option value="0">待审核</option>
                                <option value="1">审核成功</option>
                                <option value="2">审核失败</option>
                            </select>
                        </div>
                    </div>
                    <!--    <div class="layui-inline">
                            <label class="layui-form-label">手机号码：</label>
                            <div class="layui-input-inline">
                                <input name="mobile" class="layui-input" id="mobile" value="" type="text"
                                       placeholder="请输入手机号码">
                            </div>
                        </div> -->
                    <div class="layui-inline">
                        <button class="layui-btn icon-btn layui-btn-sm" data-id="table_id" lay-filter="search"
                                lay-submit="">
                            <i class="layui-icon"></i>搜索
                        </button>
                        <button type="reset" class="layui-btn icon-btn layui-btn-normal layui-btn-sm"><i
                                class="layui-icon layui-icon-refresh"></i>{:__('Reset')}
                        </button>
                    </div>
                </div>
            </form>
        </div>
    </div>


    <div class="layui-card">
        <div class="layui-card-body">
            <table class="layui-hide" id="table_id" lay-filter="table_id"></table>
        </div>
    </div>

</div>
{/block}

{block name="js"} <!--js处理区-->

<script type="text/html" id="operationTpl">
    <a href="javascript:;" class="layui-btn layui-btn-primary layui-btn-xs {:node('BalanceAudit/del')}"
       data-title="详情"
       lay-event="detail"><i class="layui-icon">&#xe705;</i></a>
    <!--    <a href="javascript:;" class="layui-btn layui-btn-danger layui-btn-xs {:node('BalanceAudit/del')}" data-title="删除"-->
    <!--       lay-event="del"><i class="layui-icon "></i></a>-->
</script>
<script>
    layui.use(['element', 'table', 'form', 'jquery', 'lucky', 'opTable', 'upload'], function () {
        var element = layui.element;
        var form = layui.form;
        var table = layui.table;
        var $ = layui.jquery;
        var lucky = layui.lucky;
        var upload = layui.upload;
        var opTable = layui.opTable;
        form.render();

        var myTables = table.render({
            elem: '#table_id',
            url: "{:url('index')}",
            toolbar: '#toolbarDemo', //开启头部工具栏，并为其绑定左侧模板
            // defaultToolbar: ['filter', 'exports', 'print'],
            defaultToolbar: ['filter', 'print'],
            even: true, //开启隔行背景
            id: 'table_id',
            page: { //支持传入 laypage 组件的所有参数（某些参数除外，如：jump/elem） - 详见文档
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip', 'last'] //自定义分页布局
                , groups: 5 //只显示 1 个连续页码
                , first: false //不显示首页
                , last: false //不显示尾页
                , limit: 20
                , limits: [10, 20, 30, 50]
            },
            // height: 'full-100',100',
            text: {
                none: '暂无相关数据'
            },
            cols: [[
                {title: '编号', field: 'id', width: 90},
                {
                    title: '品牌名称', field: 'merchant', templet: function (item) {
                        return item.name
                    }
                },
                {
                    title: '签约公司', field: 'merchant', templet: function (item) {
                        return item.company
                    }
                },
                {
                    title: '合同号', field: 'merchant', templet: function (item) {
                        return item.code
                    }
                },
                {
                    title: '交易金额（元）', field: 'amount', templet: function (item) {
                        return item.amount / 100
                    }
                },

                {
                    title: '交易类型', field: 'is_top_up', width: 90, templet: function (item) {
                        return '转账'
                    }
                },
                {
                    title: '交易时间', field: 'create_time', templet: function (item) {
                        if (item.create_time) {
                            return layui.util.toDateString((item.create_time) * 1000, 'yyyy-MM-dd HH:mm:ss');
                        } else {
                            return '';
                        }
                    }
                },
                {
                    title: '转账时间', field: 'up_time'
                },
                {
                    title: '审核状态', field: 'status', templet: function (item) {
                        if (item.status==0) {
                            return '待审核';
                        } else if(item.status==1) {
                            return '审核成功';
                        }else{
                            return '审核失败';
                        }
                    }
                },
                {
                    title: '审核时间', field: 'create_time', templet: function (item) {
                        if (item.suggest_time) {
                            return layui.util.toDateString((item.suggest_time) * 1000, 'yyyy-MM-dd HH:mm:ss');
                        } else {
                            return '';
                        }
                    }
                },
                {templet: '#operationTpl', width: 100, fixed: 'right', align: 'center', title: '操作'}
            ]],
            //  展开的列配置
            openCols: [
                {field: 'desc', title: '描述信息'}
            ],
            done: function (res) {
                layer.closeAll('loading');
            }
        });
        /**
         * 监听单行工具操作
         */
        table.on('tool(table_id)', function (obj) {
            var data = obj.data;
            var _id = parseInt(data.id);
            var layEvent = obj.event;
            if (layEvent === "detail") {
                var urls = "{:url('detail')}?id=" + _id;
                lucky.CreateOpenForm("编辑", urls);

            } else if (layEvent === "del") {
                lucky.FormatData(_id, "{:url('del')}");
            }
        });


        table.on('toolbar(table_id)', function (obj) {
            var checkStatus = table.checkStatus(obj.config.id);
            var data = checkStatus.data;
            if (obj.event === "detail") {
                lucky.CreateOpenForm("添加", "{:url('add')}");
                return false;
            } else if (obj.event === "close") {
                opTables.closeAll();
            } else if (obj.event === "open") {
                opTables.openAll();
            } else if (obj.event === "reload") {
                lucky.CreateReload();
            } else if (obj.event === "del") {
                var num = 0;
                var id = [];
                for (var i in data) {
                    num++;
                    id.push(data[i].id);
                }
                if (num < 1) {
                    layer.msg("请选择一项", {time: 1500});
                    return false;
                }
                lucky.FormatData(id, "{:url('del')}");
                return false;
            }
        });

        /**
         * 关键词搜索树
         */
        form.on('submit(search)', function (obj) {
            lucky.CreateSearch(obj.field);
            return false;
        });
    });

</script>

{/block}
